home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / disp182a.zip / DRVSRC / ATI_16MD.ASM < prev    next >
Assembly Source File  |  1994-05-14  |  16KB  |  578 lines

  1. ;--------------------------------------------------------------------------
  2. ; This is file ATI_16M.ASM,  Version 0.3
  3. ;
  4. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  5. ; Copyright (C) 1992 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
  6. ; Copyright (C) 1994 Bernhard Schwall (ATI-parts)
  7. ;
  8. ; This file is distributed under the terms listed in the document
  9. ; "copying.dj", available from DJ Delorie at the address above.
  10. ; A copy of "copying.dj" should accompany this file; if not, a copy
  11. ; should be available from where this file was obtained.  This file
  12. ; may not be distributed without a verbatim copy of "copying.dj".
  13. ;
  14. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  15. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. ;--------------------------------------------------------------------------
  17. ;
  18. ; changes:
  19. ;
  20. ; Version 0.1:    07.02.1994
  21. ;    first release
  22. ;
  23. ; Version 0.2:    09.02.1994
  24. ;    fixed the byte/line to really needed size, so 640x480x16.7mio
  25. ;    will fit in 1MB-Ram
  26. ;    clear 2.MB when using 16.7mio. colormode
  27. ;
  28. ; Version 0.3:    16.02.1994
  29. ;    return the right number of planes
  30. ;    changed 24 bit mode to BGR-order
  31. ;    so disp160 will run in truecolor
  32. ;    
  33. ; Version 0.31: 31.03.1994
  34. ;       set screenwidth to original value when switching to textmode
  35. ;       changed the standard setup: disable memory aperture
  36. ;       changed grdriver.inc to new verson shipped with LIBGRX 1.03 which
  37. ;            now uses disp180 too.
  38. ;
  39. ;--------------------------------------------------------------------------
  40.  
  41. include grdriver.inc
  42. cseg    segment byte public 'code'
  43.     assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  44.  
  45.  
  46. ;--------------------------------------------------------------------------
  47. ; DRIVER HEADER
  48. ;  The following entries MUST match the structure and constant
  49. ;  declarations in the file 'grdriver.h' of the GRX graphics library
  50. ;  The mode word should contain the following bitfields:
  51. ;     - the GRD_NEW_DRIVER bit set for any new format driver
  52. ;     - the adapter type field should be specified
  53. ;     - the memory size field should be specified
  54. ;     - the paging mode field should be specified
  55. ;  The mode set routine will OR in the plane bitfield as it will
  56. ;  change when different color number modes are requested.
  57. ;--------------------------------------------------------------------------
  58.  
  59.     dw    offset mode_set_routine
  60.     dw    offset paging_routine
  61. mode_W  dw    GRD_NEW_DRIVER+GRD_VGA+GRD_1024K+GRD_RW_64K
  62. ;
  63. ; The 'def_xx' fields are filled in by go32 from the corresponding
  64. ; fields of the 'GO32' environment variable
  65. ;
  66. def_tw  dw    80        ; text width
  67. def_th  dw    25        ; text height
  68. def_gw  dw    640        ; graphics width
  69. def_gh  dw    480        ; graphics height
  70. def_nc  dw    16        ; graphics colors
  71.     dw    offset driver_init_routine
  72.     dw    offset text_mode_table
  73.     dw    offset graphics_mode_table
  74.  
  75. ;
  76. ; Biggest text and graphics sizes
  77. ;
  78. Max_TW  equ    80
  79. Max_TH  equ    50
  80. Max_GWn equ    800        ; non interlaced!!!
  81. Max_GHn equ    600
  82. Max_GW  equ    1024        ; may be interlaced
  83. Max_GH  equ    768
  84.  
  85. ;--------------------------------------------------------------------------
  86. ; TABLE OF SUPPORTED TEXT MODES
  87. ;    - keep sorted by size
  88. ;    - end with an all 0 entry
  89. ;    - BIOS field = 0xff disables it
  90. ;    - fields:
  91. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  92. ;--------------------------------------------------------------------------
  93. text_mode_table        label word
  94.     dw    80,    25,    2,    007h +  00000h
  95.     dw    40,    25,    16,    001h +  00000h
  96.     dw    80,    25,    16,    003h +  00000h
  97.     dw    80,    28,    16,    003h +  00100h
  98.     dw    80,    50,    16,    003h +  00200h
  99.     dw    132,    25,    16,    023h +  00000h
  100.     dw    132,    28,    16,    023h +  00100h
  101.     dw    132,    44,    16,    033h +  00000h
  102.     dw    0,    0,    0,    000h +  00000h
  103.  
  104. ;--------------------------------------------------------------------------
  105. ; TABLE OF SUPPORTED GRAPHICS MODES
  106. ;    - keep sorted first by colors then by size
  107. ;    - end with an all 0 entry
  108. ;    - BIOS field = 0xff disables it
  109. ;    - fields:
  110. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  111. ;--------------------------------------------------------------------------
  112. graphics_mode_table    label word
  113.     dw    320,    200,    16,    00dh +  00000h
  114.     dw    640,    200,    16,    00eh +  00000h
  115.     dw    640,    350,    16,    010h +  00000h
  116.     dw    640,    480,    16,    012h +  00000h
  117.     dw    800,    600,    16,    054h +  00000h
  118.     dw    1024,    768,    16,    055h +  00000h
  119.     dw    320,    200,    256,    013h +  00000h
  120.     dw    640,    400,    256,    061h +  00000h
  121.     dw    640,    480,    256,    062h +  00000h
  122.     dw    800,    600,    256,    063h +  00000h
  123.     dw    1024,    768,    256,    064h +     00000h
  124.     dw    640,    480,    32768,    062h +    00300h
  125.     dw    800,    600,    32768,    063h +    00300h
  126.     dw    1024,    768,    32768,    064h +    00300h
  127.     dw    640,    480,    49168,    062h +    00310h    ; 49168 = 0xc000+16
  128.     dw    800,    600,    49168,    063h +    00310h
  129.     dw    1024,    768,    49168,    064h +    00310h
  130.     dw    640,    480,    49176,    062h +  00380h    ; 49176 = 0xc000+24
  131.     dw    800,    600,    49176,    063h +    00380h
  132.     dw    0,    0,    0,    000h +  00000h
  133.  
  134. ;--------------------------------------------------------------------------
  135. ; TABLE OF SPECIAL SETUP PROCEDURES
  136. ;  You may need such procedures for:
  137. ;     -- reloading fonts on standard EGA or VGA for
  138. ;     higher resolution text modes
  139. ;     -- enable HiColor mode of some Super VGAs
  140. ;     -- Handle the parameter passing conventions of the VESA BIOS
  141. ;     -- put VGA into 256 color plane mode ("MODE X")
  142. ;     -- etc...
  143. ;  There should be one entry in the table for every non-zero
  144. ;  'setup_procedure_index' in the text and graphics mode tables.
  145. ;  The first entry in the table belongs to index 100h, and so on.
  146. ;  The special setup procedure is invoked via a near call.
  147. ;
  148. ;  Entry: DI=address of the mode record from the text or graphics
  149. ;      table to set up.
  150. ;
  151. ;  Exit:  Adapter configured
  152. ;      BX=driver mode word as it should be returned by the mode set
  153. ;         routine. Typically it involves picking up the mode word
  154. ;         from the header and OR-ing in the appropriate bitplane mode
  155. ;         bitfield. (This is not needed for text modes)
  156. ;      AX, SI can be trashed, PRESERVE DI!!!!
  157. ;
  158. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  159. ;--------------------------------------------------------------------------
  160. special_setup_table    label word
  161.     dw    offset  VGA_28row_mode_set
  162.     dw    offset  VGA_50row_mode_set
  163.     dw    offset    ATI_setup        ; setup 15, 16 and 24 bit
  164. ;
  165. ; Routine to set up VGA 50 row mode
  166. ; interface is described above
  167. ;
  168. VGA_50row_mode_set    proc    near
  169.     mov    ax,03h            ; set 80x25 mode
  170.     int    10h
  171.     xor    bx,bx
  172.     mov    ax,1112h        ; load 8x8 font
  173.     int    10h
  174.     ret
  175. VGA_50row_mode_set    endp
  176.  
  177. VGA_28row_mode_set    proc    near
  178.     mov    ax,WORD PTR [di+6]    ; set 25 line mode
  179.     xor    ah,ah
  180.     int    10h
  181.     xor    bx,bx
  182.     mov    ax,1111h        ; load 8x14 font
  183.     int    10h
  184.     ret
  185. VGA_28row_mode_set    endp
  186.  
  187. ; Routine to initialize 16.7milion color mode on ATI GU+ GUpro
  188.  
  189. ATI_Accell db 0
  190. ATI_lo     dw 0
  191. ATI_hi     dw 0
  192.  
  193. ATI_setup    proc near
  194.     mov     ax,word ptr [di+6]
  195.     and     ax,006fh
  196.     int    10h            ; switch to graphicsmode
  197.     mov    cx,ax
  198.     and    ax,006fh
  199.     cmp    ax,63h
  200.     jl    No2MB
  201.     mov    dx,01ceh        ; get old value of ATI2E
  202.     mov    al,0aeh    
  203.     out    dx,al
  204.     inc    dx
  205.     in    al,dx
  206.     and    al,0f0h
  207.     or    al,05
  208.     out    dx,al            ; set read/write-bank to 2.MB
  209.     mov    ax,cx
  210.     int    10h            ; switch to graphicsmode second time
  211.                     ; to clear 2.MB
  212.     mov    dx,01ceh        ; get old value of ATI2E
  213.     mov    al,0aeh    
  214.     out    dx,al
  215.     inc    dx
  216.     in    al,dx
  217.     and    al,0f0h
  218.     out    dx,al            ; set read/write-bank to 1.MB
  219. No2MB:    mov    dx,52eeh
  220.     in    ax,dx
  221.     and    ax,007fh
  222.     mov    cl,7
  223.     shl    ax,cl
  224.     add    ax,0c000h
  225.     mov    ATI_hi,ax
  226.     mov    ax,0064h
  227.     mov    ATI_lo,ax        ; get Rom-Entry-Point
  228. ; select colordepth
  229.     mov    cl,byte ptr [di+6]
  230.     test    cl,80h
  231.     jz    No_888
  232.     mov    ah,07h            ; 888
  233.     mov    bx,GRD_24_PLANES
  234.     push    bx
  235.     jmp    SelRes
  236. No_888: test    cl,10h
  237.     jz    No_565
  238.     mov    ah,0dh            ; 565
  239.     mov    bx,GRD_16_R_PLANES
  240.     push    bx
  241.     jmp    SelRes
  242. No_565:    mov    ah,05h            ; 555
  243.     mov    bx,GRD_16_PLANES
  244.     push    bx
  245. ; select resolution
  246. SelRes: and    cl,6fh
  247.     cmp    cl,62h
  248.     jnz    No640
  249.     mov    al,21h            ; 640x480
  250.     jmp    SetRes
  251. No640:    cmp    cl,63h
  252.     jnz    No800
  253.     mov    al,01h            ; 800x600
  254.     jmp    SetRes
  255. No800:    mov    al,41h            ; 1024x768
  256. SetRes:    mov    bx,3
  257.     call    dword ptr [ATI_lo]    ; set resolution and colordepth
  258.     mov    ax,0068h
  259.     mov    ATI_lo,ax
  260.     mov    ax,1
  261.     call    dword ptr [ATI_lo]